(defconstant e   2.718281828459045)

(defun adash () (/ 1.0 most-positive-fixnum))

(defun mean (n sum)
  (/ sum n))

(defun stdev (n sum sumSq) 
  (sqrt (/ (- sumSq (/ (* sum sum) n)) (- n 1))))

(defun normal (m s) 
  (let ((deltam (* s (box_muller))))
    (if (>= (my-randone) 0.5)
        (+ m deltam)
        (- m deltam))))

(defun box_muller ()
  (multiple-value-bind (w x) (w)
    (* x  (sqrt (/ (* -2.0 (log w)) w)))))

(defun w ()
  (let* ((x1 (* 2.0 (my-randone)))
         (x2 (* 2.0 (my-randone)))
         (w  (+ (* x1 x1) (* x2 x2))))
    (if (> w 1)
        (w)
        (values w x1))))